(function() {
    'use strict';

    /**
     * @ngdoc function
     * @name webApp.controller:SelleruserCtrl
     * @description
     * # SelleruserCtrl
     * Controller of the webApp
     */
    angular.module('webApp').controller('SelleruserCtrl', SelleruserCtrl);

    SelleruserCtrl.$inject = ['$scope', 'dataService', '$location', '$state', 'helper', '$rootScope', 'sessionService', '$timeout'];

    function SelleruserCtrl($scope, dataService, $location, $state, helper, $rootScope, sessionService, $timeout) {
        //显示
        $scope.listAction = function() {
            $scope.getUserInfo();
        }
        //获取信息
        $scope.getUserInfo = function() {
            dataService.sellerUserCurrentGet().then(function(list) {
                if (list) {
                    $scope.user =clone(list) ;
                    $scope.user_nametype = list.user_name.length >=28?"":"1";
                    console.error($scope.user_nametype);
                }
            });
        }



        //修改数据
        $scope.Update = function() {
            if($scope.user.password !==$scope.user.password_confirm){
                helper.myAlert("两次输入密码不一致！");
                return false;
            }
            var data = {
                "user_name": $scope.user.user_name,
                "password": $scope.user.password,
                "password_confirm": $scope.user.password_confirm,
                "mobile": $scope.user.mobile,
                "avatar": $scope.user.avatar,
                "email": $scope.user.email
            }

            dataService.sellerUserUpdate(data).then(function(retu) {
                if (retu) {
                    helper.myAlert("success ");
                    $scope.getUserInfo();
                } else {
                    helper.myAlert("error ");
                }
            });
        }
    }
})();